#include "led_rgb_pwm.h"
#include "smart_pwm.h"
#include "can_signal.h"
/*
 * 函数介绍: 混光算法测试
 * 参数:
 * 返回值: {*}
 * 备注:
 */
void led_rgb_pwm_test(void)
{
    Led_pwm led_pwm_st;
#if UNLOCK_TEST /*OBU发出车辆解锁信号*/
    led_pwm_st.R_PWM = COLOR_YELLOW_PWM_R;
    led_pwm_st.G_PWM = COLOR_YELLOW_PWM_G;
    led_pwm_st.B_PWM = COLOR_YELLOW_PWM_B;
#endif
#if LOCK_TEST /*OBU发出车辆上锁信号*/
    led_pwm_st.R_PWM = COLOR_YELLOW_PWM_R;
    led_pwm_st.G_PWM = COLOR_YELLOW_PWM_G;
    led_pwm_st.B_PWM = COLOR_YELLOW_PWM_B;
#endif
#if TURN_LEFT_TEST /*OBU发出车辆左转信号*/
    led_pwm_st.R_PWM = COLOR_BLUE_PWM_R;
    led_pwm_st.G_PWM = COLOR_BLUE_PWM_G;
    led_pwm_st.B_PWM = COLOR_BLUE_PWM_B;
#endif
#if TURN_RIGHT_TEST /*OBU发出车辆右转信号*/
    led_pwm_st.R_PWM = COLOR_BLUE_PWM_R;
    led_pwm_st.G_PWM = COLOR_BLUE_PWM_G;
    led_pwm_st.B_PWM = COLOR_BLUE_PWM_B;
#endif
#if WARNING_TEST /*OBU发出预警信号*/
    led_pwm_st.R_PWM = COLOR_RED_PWM_R;
    led_pwm_st.G_PWM = COLOR_RED_PWM_G;
    led_pwm_st.B_PWM = COLOR_RED_PWM_B;
#endif
#if CHARGE_TEST /*OBU发出充电测试*/
    led_pwm_st.R_PWM = COLOR_GREEN_PWM_R;
    led_pwm_st.G_PWM = COLOR_GREEN_PWM_G;
    led_pwm_st.B_PWM = COLOR_GREEN_PWM_B;
#endif

    st_Led_pwm_now(led_pwm_st);
    st_Led_Dim_upperlimit_now(DIM_MAX_VALUE);
}

/*
 * 函数介绍: 混光算法主函数,将三色的PWM装填到Led_pwm中
 * 参数:
 * 返回值: {*}
 * 备注:
 */
void led_rgb_pwm_main(void)
{
    //led_rgb_pwm_test();
#if 1
    Led_pwm led_pwm_st;
    if (NEW_INS == rt_Rgb_now())
    {
        switch (rt_L_mode())
        {
            case LIGHT_EFFECT_SIGNAL_MAX:
                break;
            case VEHICLE_UNLOCKING: /*填装解锁信号颜色*/
                led_pwm_st.R_PWM = COLOR_YELLOW_PWM_R;
                led_pwm_st.G_PWM = COLOR_YELLOW_PWM_G;
                led_pwm_st.B_PWM = COLOR_YELLOW_PWM_B;
                break;
            case VEHICLE_LOCKING: /*填装上锁信号颜色*/
                led_pwm_st.R_PWM = COLOR_YELLOW_PWM_R;
                led_pwm_st.G_PWM = COLOR_YELLOW_PWM_G;
                led_pwm_st.B_PWM = COLOR_YELLOW_PWM_B;
                break;
            case VEHICLE_TURNING_LEFT: /*填装左转信号颜色*/
                led_pwm_st.R_PWM = COLOR_BLUE_PWM_R;
                led_pwm_st.G_PWM = COLOR_BLUE_PWM_G;
                led_pwm_st.B_PWM = COLOR_BLUE_PWM_B;
                break;
            case VEHICLE_TURNING_RIGHT: /*填装右转信号颜色*/
                led_pwm_st.R_PWM = COLOR_BLUE_PWM_R;
                led_pwm_st.G_PWM = COLOR_BLUE_PWM_G;
                led_pwm_st.B_PWM = COLOR_BLUE_PWM_B;
                break;
            case VEHICLE_WARNING: /*填装预警信号颜色*/
                led_pwm_st.R_PWM = COLOR_RED_PWM_R;
                led_pwm_st.G_PWM = COLOR_RED_PWM_G;
                led_pwm_st.B_PWM = COLOR_RED_PWM_B;
                break;
            case VEHICLE_RELEASE_WARNING: /*填装解除预警信号颜色*/
                led_pwm_st.R_PWM = RGB_PWM_CLOSE;
                led_pwm_st.G_PWM = RGB_PWM_CLOSE;
                led_pwm_st.B_PWM = RGB_PWM_CLOSE;
                break;
            case VEHICLE_CHARGING: /*填装充电信号颜色*/
                led_pwm_st.R_PWM = COLOR_GREEN_PWM_R;
                led_pwm_st.G_PWM = COLOR_GREEN_PWM_G;
                led_pwm_st.B_PWM = COLOR_GREEN_PWM_B;
                break;
            default:
                break;
        }
        st_Led_pwm_now(led_pwm_st);
        st_Led_Dim_upperlimit_now(DIM_MAX_VALUE);
        st_Rgb_now(NO_INS);
    }
#endif
}

